//
//  HotCityPositionTableViewCell.m
//  MemberProject
//
//  Created by mac on 15/4/30.
//  Copyright (c) 2015年 MAC OS X. All rights reserved.
//

#import "HotCityPositionTableViewCell.h"
#import "CityPositionCollectionViewCell.h"
@implementation HotCityPositionTableViewCell

- (void)awakeFromNib {
    // Initialization code
    self.collectionView.backgroundColor=[UIColor colorWithRed:236/255.0 green:235/255.0 blue:232/255.0 alpha:1];
    self.collectionView.dataSource=self;
    self.collectionView.delegate=self;
    [self.collectionView registerNib:[UINib nibWithNibName:@"CityPositionCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"CellIdentifier"];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

#pragma mark - collectionView delegate
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return self.data.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *CellIdentifier=@"CellIdentifier";
    CityPositionCollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
    cell.textLabel.text=self.data[indexPath.row][@"name"];
    cell.selectedBackgroundView.frame=CGRectMake(0, 0, (collectionView.width-10*4)/3, 40);
    return cell;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    return CGSizeMake((collectionView.width-10*4)/3, 40);
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    [collectionView deselectItemAtIndexPath:indexPath animated:YES];
    if([self.delegate respondsToSelector:@selector(HotCityPositionTableViewCell:collectionView:didSelectItemAtIndexPath:)]){
        [self.delegate HotCityPositionTableViewCell:self collectionView:collectionView didSelectItemAtIndexPath:indexPath];
    }
    
}
@end
